﻿using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif

namespace Assetbundles
{
    public class AssetbundleUtility
    {
        public static string GetCurrentPlatformName()
        {
#if UNITY_EDITOR
            return GetPlatformName(EditorUserBuildSettings.activeBuildTarget);
#else
            return GetPlatformName(Application.platform);
#endif
        }

#if UNITY_EDITOR
        /// <summary>
        /// Editor Mode
        /// </summary>
        /// <param name="platform"></param>
        /// <returns></returns>
        private static string GetPlatformName(BuildTarget platform)
        {
            switch(platform)
            {
                case BuildTarget.Android:return "Android";
                case BuildTarget.iOS:return "IOS";
                case BuildTarget.StandaloneWindows:
                case BuildTarget.StandaloneWindows64:return "Windows";
                default:return null;
            }
        }
#endif
        /// <summary>
        /// Runtime
        /// </summary>
        /// <param name="platform"></param>
        /// <returns></returns>
        private static string GetPlatformName(RuntimePlatform platform)
        {
            switch(platform)
            {
                case RuntimePlatform.Android:return "Android";
                case RuntimePlatform.IPhonePlayer:return "IOS";
                case RuntimePlatform.WindowsPlayer: return "Windows";
                default:return null;
            }
        }
       

    }
}
